<?php
include_once "Telephone.php";
include_once "Administrador.php";
include_once "Client.php";

class UserControl{
	public static function loginUser($login, $password){
		include_once "User.php";
		$user = User::authenticateUser($login, $password);
			return $user;
	}
	
	public static function cadastreAdmin($label_name, $label_cpf, $label_sex, $label_password, $label_confirmPassword)
	{
		if($label_password == $label_confirmPassword)
		{
			$result = Administrador::cadastraAdmin($label_name, $label_cpf, $label_password, $label_name, $label_sex);
			if($result)
			{				
				return true;				
			}
			else
			{
				return false;				
			}
		}
		
	}
	
	public static function cadastreClient($label_name, $label_login, $label_cpf, $label_sex, $label_telephone, $label_celular, 
		$label_email, $label_password, $label_confirmPassword, $label_cep, $label_state, $label_city, 
		$label_adress, $label_complement, $label_district, $label_country, $label_data)
	{
		
		if($label_password == $label_confirmPassword)
		{		
			
			$result = Client::cadastraClient($label_cpf, $label_password, $label_login, $label_name, $label_sex, $label_email,
			$label_data, $label_adress, $label_complement, $label_district, $label_city, $label_state, $label_country, $label_cep);
		
			if($result)
			{
				Telephone::cadastraTelephone($label_cpf, $label_telephone, 0);
				Telephone::cadastraTelephone($label_cpf, $label_celular, 1);
				return true;				
			}
			else
			{
				return false;				
			}			
		}			
	}
	
	public static function atualizaCliente($varIdCliente, $label_name, $label_login, $label_cpf, $label_sex, $label_telephone, $label_celular, 
		$label_email, $label_password, $label_confirmPassword, $label_cep, $label_state, $label_city, 
		$label_adress, $label_complement, $label_district, $label_country, $label_data)
		{
			if($label_password == $label_confirmPassword)
			{
				$result = Client::updateClient($varIdCliente,$label_cpf, $label_password, $label_login, $label_name, $label_sex, $label_email,
				$label_data, $label_adress, $label_complement, $label_district, $label_city, $label_state, $label_country, $label_cep);
				if($result)
				{
					Telephone::updateTelephone($label_cpf, $label_telephone, 0);
					Telephone::updateTelephone($label_cpf, $label_celular, 1);
					return true;				
				}
				else
				{
					return false;				
				}	
			}
		}
		
	public static function atualizaAdmin($varIdAdmin, $label_name, $label_login, $label_cpf, $label_sex, $label_password, $label_confirmPassword)
		{
			if($label_password == $label_confirmPassword)
			{
				$result = Administrador::updateAdmin($varIdAdmin, $label_name, $label_login, $label_cpf, $label_password, $label_sex);
				if($result)
				{
					return true;				
				}
				else
				{
					return false;				
				}	
			}
		}
	
	public static function getCliente($id_cliente)
	{
		$resultClient = Client::GetCliente($id_cliente);
		
		return $resultClient;		
	}
	
	public static function getAdmin($id_admin)
	{
		
		$resultAdmin = Administrador::getAdministrador($id_admin);
		return $resultAdmin;
	}
	
	public static function GetAllClientes()
	{
		$resultClient = Client::GetAllClientes();
	
		return $resultClient;	
	}
	
}
?>